package com.yuanyefu.MQlearn;

import com.aliyun.openservices.ons.api.*;
import com.yuanyefu.jdbc.Student;

import java.util.Properties;

/**
 * Created by 339814 on 2017/9/18.
 */
public class ProducerTest{

    public static void main(String[] args){

        Properties properties = new Properties();
        properties.put(PropertyKeyConst.ProducerId,"PID_m5173test");
        properties.put(PropertyKeyConst.AccessKey,"GRWdJPdv2nQMCybv");
        properties.put(PropertyKeyConst.SecretKey,"WqMdhwY7GFaj4Kf4G9wRdkKVeRZQr3");
        properties.put(PropertyKeyConst.ONSAddr,
                "http://onsaddr-internet.aliyun.com/rocketmq/nsaddr4client-internet");

        Producer producer = ONSFactory.createProducer(properties);
        producer.start();
        Student student = new Student(10001,"yuanyefu",24);
        while (true){
            for (int i=10;i<20;i++){
                Message message = new Message("m5173test","TagA",("Hellow yyf"+i).getBytes());


                SendResult send = producer.send(message);
                System.out.println("Send Message success. Message ID is: "+ send.getMessageId());
            }
            //message.setKey("ORDERID_100");
            producer.shutdown();
        }
    }



}
